--[[
CodeAll  v0.1
CODEBY:WINGER[freelight]
一个编码转换工具,用于网络安全检测
下个版本写成可自定义模板的,就相当于无限扩展了
只要你知道基本lua语法就行
-----------------------------------------------------------------
本程序为自由软件；您可依据自由软件基金会所发表的GNU通用公共授权条款，
对本程序再次发布和/或修改；无论您依据的是本授权的第三版，
或（您可选的）任一日后发行的版本。
本程序是基于使用目的而加以发布，然而不负任何担保责任；
亦无对适售性或特定目的适用性所为的默示性担保。
详情请参照GNU通用公共授权。
您应已收到附随于本程序的GNU通用公共授权的副本；如果没有，请参照
<http://www.gnu.org/licenses/>.
-----------------------------------------------------------------
欢迎大家在下述网页发帖或来信说明讨论该软件的BUG和可以改进之处
Webs	: groups.google.is/group/freelala
Blog	: freewinger.blogspot.com
E-mail	: free.winger@GMail.com
QQ	: 292474745
]]
function code_print(source,ary,ext) 
--	   io.write("\n")
		if(source and source~="")then
			io.write(string.byte(source))
		 		if (ary=="%bin") then
	  	  	 	for w in string.gmatch(source, ".") do
		 		 			io.write(numberstring(string.byte(w),2))
			 				end
				else	
    		 		for w in string.gmatch(source, ".") do
      				 io.write(string.format(ary,string.byte(w)))
    	 			end
	 			end
		  over=ext and  io.write(ext)
		else
			io.write("\n")
		end
end

digits = {}
for i=0,9 do digits[i] = string.char(string.byte('0')+i) end
for i=10,36 do digits[i] = string.char(string.byte('A')+i-10) end

function numberstring(number, base)
   local s = ""
   repeat
      local remainder = math.mod(number,base)
      s = digits[remainder]..s
      number = (number-remainder)/base
   until number==0
   return s
end



function code_mix(source)
	local parsed = {}
	 io.write("HEx:\n")
     code_print(source,"%X","\n")
	 	 code_print(source,"%X ","\n")
		 code_print(source,"%X,","\n")
	   
		 io.write("Octal:\n")
     code_print(source,"%o","\n")
     code_print(source,"%o ","\n")
		 code_print(source,"%o,","\n")

	   io.write("Ascii:\n")
     code_print(source,"%d","\n")
     code_print(source,"%d ","\n")
		 code_print(source,"%d,","\n")
			
		io.write("\nMSSQL_ENCODE\n")
		io.write("dEcLaRe @s vArChAr(8000) sEt @s= 0x")
	 	code_print(source,"%X")
		io.write(" eXeC(@s)--\n")

    io.write("\nMysql_LoadFile\n")
		io.write("replace(load_file(0x")	
	 	code_print(source,"%X")
    io.write("),0x3c,0x20))\n")
		
	 	io.write("\nURL-Encode1:\n")
	 x,_=string.gsub(source, "([^A-Za-z0-9_.])", function(c)return(string.format("%%%02x", string.byte(c))) end)
	 	io.write(x..'\n')
	  io.write("\nURL-Encode2:\n")
	 --x=string.gsub(source, "//(.-)/", function(c)return(string.format("%%%02x", string.byte(c))) end)
	string.gsub(source, "^http://([^/]+)",
		function(c)
			for w in string.gmatch(c, ".") do
				io.write(string.format("%%%02x",string.byte(w)))
			end
		end)



	   io.write("\nbin:\n")
     code_print(source,"%bin","\n")

--[[[	 for w in string.gmatch(source, "^//([^/]*)") do
		for z in string.gmatch(w, ".") do
			io.write(string.format("%X",string.byte(w)))
		end
     end]]

	for i,v in pairs(parsed) do

	end
		
end

print([[
					ColdAll v0.1
					License:GPL3
					fff=:to exit app!
					Good luck !
					free.winger@gmail.com
			]])

while true do
source_str = io.read()
if(source_str and source_str ~="" )then 
	source_str=source_str=="fff="and (io.write("good by lady!\n")and os.exit())or code_mix(source_str)
else
	io.write("Input Something Uncle!\n")
end
source_str = nil
end
